<template>
	<div>
		<div id="top1">
			缺陷分配
		</div>
		<div class="one1">	
			<div>缺陷编号：{{recordBug.recordId}}</div>
		</div>
		<div class="one1">
			<div>预计耗时：{{recordBug.ptime}}</div>
		</div>
		<div class="one1">
			<div>开始处理时间：{{recordBug.starttime}}</div>
		</div>
		<div class="one1">
			<div>当前进度：

			<select v-model="recordState">
				<option v-for="state in stateList">{{state}}</option>
			</select>
			
			</div>
		</div>
		<div class="one1">
			<div>处理人：{{recordBug.dealbyName}}</div>
		</div>
		<div class="one1">
			<input type="button" value="处理代码下载" @click="download()" />
		</div>
		<div class="one1">
			反馈描述：
		</div>
		<div class="one1">
			<input type="tel" v-model="comment.comments" />
		</div>
		<div class="one1">
			<input type="button" value="保存" @click="insertDealTime()"/>
		</div>
	</div>
</template>

<script>
	import $ from "jquery"
	export default {
	  name: "BugFeedback",
	  data:function() {
		  return {
			  recordState:"",
			  stateList:[],
			  comment:{},
			  dealName:"",
			  recordBug:{},
			  nameList:[],
			  dealTime:{
				  bugId:"",
				  ptime:"",
				  dealbyName:"",
				  recordState:"待处理"
			  }
		  }
	  },
	  created:function(){
		this.select();
		this.selectAllState();
	  },
	  methods: {
		  select:function(){
			  var ts = this;
			  var bugId=this.$route.query.bugId;
			  $.ajax({
				  url:"http://localhost/bugDistribution/queryDeal",
				  type:"get",
				  data:{"bugId":bugId},
				  headers:{"token":localStorage.getItem("token")},
				  success:function(data){
					  ts.recordBug = data.obj;
					  $.ajax({
					  	url:"http://localhost/user/userInfo",
					  	type:"get",
					  	headers:{"token":localStorage.getItem("token")},
					  	success:function(data){
					  		ts.comment.confirmbyName = data.obj.userName;			  
					  	},
					  })
				  }
				  
			  })
		  },
		  selectAllState:function(){
		  			  var ts = this;
		  			  	$.ajax({
		  			  	url:"http://localhost/bugDistribution/queryAllState",
		  			  	type:"get",
		  			  	headers:{"token":localStorage.getItem("token")},
		  			  	success:function(data){
		  			  	ts.stateList = data.list;
		  			  	} 
		  			  })
		  },
		  
		  insertDealTime:function(){
			  var ts = this;
			  this.comment.dealstate=this.$route.query.dostate;
			  this.comment.bugId=this.$route.query.bugId;
			  var bugId=this.$route.query.bugId;
			  $.ajax({
			  	url:"http://localhost/bugDistribution/comment",
			  	type:"post",
			  	data:ts.comment,
				headers:{"token":localStorage.getItem("token")},
			  	success:function(data){
					$.ajax({
						url:"http://localhost/bugDistribution/updateDealTime",
						type:"post",
						data:{"bugId":bugId,"recordState":ts.recordState,"recordId":ts.recordBug.recordId},
						headers:{"token":localStorage.getItem("token")},
						success:function(data){
							$.ajax({
								url:"http://localhost/bugList/update",
								type:"post",
								data:{"bugId":bugId,"dostate":ts.recordState},
								headers:{"token":localStorage.getItem("token")},
								success:function(data){
												
								}  				  
							});			
						}  				  
					});
			  	}  				  
			  });
			  $("#lk").attr("style","display: none")
			  this.$router.push("/Feedback")
		  },
		  download:function(){
			  var t = this.recordBug.fileAddress;
			  console.log(t);
			  location.href=this.recordBug.fileAddress
		  }
	  }
	}
</script>

<style>
	#top1{
		height: 30px;
		width: 100%;
		float: left;
		background-color: #cecece;
		text-align: center;
		line-height: 30px;
	}
	.one1{
		height: 30px;
		width: 100%;
		float: left;
		background-color: #e1e1e1;
		text-align: center;
		line-height: 30px;
	}
</style>
